<template>
  <el-card shadow="never">
    <el-card shadow="never" v-for="item in configList" :key="item.key" v-show="item.key === 'RESET_MARKETING_DATA_DAY'">
      <template #header>
        营销分单回收设置
      </template>
      <div>从营销分单日起，
        <el-input style="width: 100px" oninput="value = value.replace(/[^\d-]/g, '')" v-model="item.value"/>
        天内未申请，系统将自动回收
      </div>

    </el-card>
    <div style="margin-top:15px;text-align: center">
      <el-button type="primary" @click="saveConfig">保存</el-button>
    </div>
  </el-card>
</template>

<script>
import {onMounted, ref} from "vue";
import {marketingConfigSearch, marketingConfigSave} from "@/api/system";
import {ElMessage} from "element-plus"

export default {
  name: "ParamConfig",
  setup() {
    const configList = ref([])

    async function getMarketingConfig() {
      const res = await marketingConfigSearch()
      if (res.code === 200) {
        configList.value = [{...res.data}]
      }
    }

    async function saveConfig() {
      const res = await marketingConfigSave({day:configList.value[0].value})
      if (res.code === 200) {
        ElMessage.success('保存成功')
        getMarketingConfig()
      }
    }

    onMounted(() => {
      getMarketingConfig()

    })
    return {
      configList,
      saveConfig
    }
  }
}
</script>

<style scoped>

</style>
